package com.tezign.intelligence.mini.dam.aifamilyconsultant.interceptor;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.extern.slf4j.Slf4j;

/**
 * @author wuzhiwei
 * @team M
 * @owner wuzhiwei
 * @Date 2022/11/3
 */
@Slf4j
public class FamilyStore {

    private FamilyStore(){}

    private static final ThreadLocal<Long> Family = new TransmittableThreadLocal<>();

    public static void setFamilyId(Long familyId){
        Family.set(familyId);
    }

    public static Long getFamilyId(){
        Long familyId = Family.get();
        return familyId == null ? 0L : familyId;
    }

    public static boolean currentlyInOrg(){
        return FamilyStore.getFamilyId()>0;
    }

    public static void clear() {
        Family.remove();
    }

}
